package com.weiyuwqj.server.service.finance.module;

import com.weiyuwqj.api.model.SysAmountOperate;
import com.weiyuwqj.server.mapper.SysAmountOperateMapper;
import com.weiyuwqj.server.mapper.SysAssetCompanyMapper;
import com.weiyuwqj.server.mapper.SysAssetProductMapper;
import com.weiyuwqj.server.service.finance.module.action.AbstractOperateAction;
import com.weiyuwqj.server.service.finance.module.action.OperateAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2017/4/26.
 */
@Component
public class OperateModule {

    @Autowired
    private SysAmountOperateMapper operateMapper;
    @Autowired
    private SysAssetCompanyMapper companyMapper;
    private int operateInsert(SysAmountOperate operate) {
        String assertName = companyMapper.getAssetNameByItemId(operate.getAssetName()).getName();
        operate.setAssetName(assertName);
        int result = operateMapper.insert(operate);
        return result;
    }

    public int operateAction(OperateAction action) {
        AbstractOperateAction act = (AbstractOperateAction) action;
        return operateInsert(act.getAmountOperate());
    }
}
